home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9234 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: H&S <=> K&R
  5. Date: 08 Mar 1996 01:10:23 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Mar7181023@qcd.lanl.gov>
  8. References: <4hnjgp$brj@cisunix1.dfci.harvard.edu>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: gotd@jimmy.harvard.edu's message of 7 Mar 1996 21:12:57 GMT
  13.  
  14. In article <4hnjgp$brj@cisunix1.dfci.harvard.edu>
  15. gotd@jimmy.harvard.edu (Godfrey Degamo) writes:
  16.  
  17. GD: First, my H&S 4th edition mentions nothing (I think) on
  18. GD: fflush with argument NULL.  However, my ANSI K&R book clearly states
  19. GD: that fflush( NULL) flushes all output stream.  My K&R book is
  20. GD: copyright 1988, my H&S book is copyright 1995.  So, has this
  21. GD: feature of ANSI C changed?  (Or am I just overlooking something?)
  22.  
  23. Yes, in ANSI, fflush(NULL) flushes all streams on which the action of
  24. fflush is defined.
  25.  
  26. GD: Second, my K&R book clearly states that the scanf conversions,
  27. GD: [...], and [^...] matches a *non-empty* string.  Whereas my H&S book
  28. GD: does not.  (I don't think it implies it... but I'm not sure...)
  29.  
  30. An empty string results in a match failure.
  31.  
  32. GD: 
  33. GD: Thus according to K&R the following will happen?
  34. GD: char buf1[] = "blahblah:123212";
  35. GD: char buf2[] = ":2313";
  36. GD: 
  37. GD: 
  38. GD: sscanf( buf1, "%[^:]:%s", s1, s2);    /* OK in K&R and H&S */
  39. GD: sscanf( buf2, "%[^:]:%s", s1, s2);    /* Error in K&R, but H&S?????? */
  40.  
  41. Not an error: you just get a return value of 0. s1 and s2 do not
  42. change. 
  43.  
  44. Cheers
  45. Tanmoy
  46. --
  47. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  48. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  49. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  50. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  51. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  52. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  53.